package com.demo.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.websocket.*;


@RestController
public class QuickController {

    @Autowired
    private WebSocket webSocket;

    @RequestMapping("/sendMsg")
    @ResponseBody
    public String sendMsg() throws Exception{
        Message message=new Message();
        message.setMessage("北京交通委提醒你：道路千万条，安全第一条，行车不规范，行人两行泪");
        message.setTo("用户a");
        String s = JSON.toJSONString(message);
        webSocket.onMessage(s,null);
        return "SUCCESS";
    }


    @PostMapping("sayHello")
    public String test() {
        return "SUCCESS";
    }


}
